<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\MessageBoardController;
use Illuminate\Support\Facades\Route;

/*
Web 路由
在这里，你可以为你的应用程序注册 Web 路由。这些路由由 RouteServiceProvider 加载，并且它们都将被分配到 “web” 中间件组。创造出伟大的东西吧！
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

//测试路由
Route::get('/greeting', function () {
    return 'Hello World';
});

/*
需要在app/Http/Controllers/创建UserController.php
指令:php artisan make:controller UserController,并添加方法
*/
Route::get('/user', [UserController::class, 'index']);

//留言板-目录/搜索结果
Route::get('/messageboard', [MessageBoardController::class, 'index'])->name('messageboard.list');
//留言板-写
Route::get('/messageboard/create', [MessageBoardController::class, 'create'])->name('messageboard.create');
Route::post('/messageboard', [MessageBoardController::class, 'store'])->name('messageboard.store');
//留言板-详情
Route::get('/messageboard/{message}', [MessageBoardController::class, 'show'])->name('messageboard.show');
//留言板-编辑
Route::get('/messageboard/{message}/edit', [MessageBoardController::class, 'edit'])->name('messageboard.edit');
Route::put('/messageboard/{message}', [MessageBoardController::class, 'update'])->name('messageboard.update');
//留言板-删除
Route::delete('/messageboard/{message}', [MessageBoardController::class, 'destroy'])->name('messageboard.destroy');

require __DIR__.'/auth.php';
